import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Response {
	HashMap<String, String> responseMap;
	
	public Response(){
		responseMap = new HashMap<String, String>();
	}
	
	public void hashResponse(String resp) {
		String[] strArray = resp.split(":");
		responseMap.put(strArray[0].trim(), strArray[1].trim());
	}
	
	public String getResponseHeaderValue(String headerType){
		return responseMap.get(headerType);
	}
	
	public void addEntry(String key, String value){
		responseMap.put(key, value);
	}
	public HashMap<String, String> getResponseMap(){
		return responseMap;
	}
	public int[] getRange(){
		String contentRange = responseMap.get("Content-Range");
		Pattern rangePattern = Pattern.compile("[0-9]*-[0-9]*");
		Matcher m = rangePattern.matcher(contentRange);
		String s = "";
		
		while (m.find()) {
		    s = m.group(0);
		}
		
		//System.err.println("Range in Response Header :"+s);
		
		int [] arr = new int[2];
		String [] arrStr = s.split("-");
		arr[0] = Integer.parseInt(arrStr[0]);
		arr[1] = Integer.parseInt(arrStr[1]);
		
		return arr;

	}
}
